package com.web.reply;

import com.service.ReplyService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class DelReplyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ReplyService service=new ReplyService();

        int id= Integer.parseInt(req.getParameter("id"));
        int remarkId=Integer.parseInt(req.getParameter("remarkId"));
        service.deleteReply(id);

        req.getSession().setAttribute("delFlag","true");
        req.getSession().setAttribute("remarkId",remarkId);
        req.getRequestDispatcher("/DisplayReply").forward(req,resp);
    }
}
